package com.daydr3am.thenation;


import org.w3c.dom.Node;

import com.daydr3am.lib.ImageLoader;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class Hilight extends SubScroll {
	public Boolean hilight=false;
    public Hilight(Context ctx, AttributeSet attrs) {
		super(ctx, attrs);
		// TODO Auto-generated constructor stub
		
	}

    public void receiveData(){
		RootScroll main=(RootScroll)((Activity)con).findViewById(R.id.bigscroll);
		int current=main.getCurrentPage();
		for(int i=0;i<list.getLength();i++){ 
			Node currentNode=list.item(i);
			if(currentNode.getChildNodes().getLength()>5){
		        LayoutInflater layoutInflater = (LayoutInflater) con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        		View pageView = layoutInflater.inflate(R.layout.hilightdetail, null);
        		this.addPage(pageView);
        		
        		TextView groupName = (TextView) pageView.findViewById(R.id.group);
        		groupName.setTextColor(TheNationMain.getColor(current, getContext()));
        		TextView titleName = (TextView) pageView.findViewById(R.id.title);
        		TextView burb = (TextView) pageView.findViewById(R.id.burb);
        		ImageView img = (ImageView) pageView.findViewById(R.id.imageView1);
        		
        		if(hilight)
        			groupName.setText("Hilight");
        		else
        			groupName.setText(currentNode.getChildNodes().item(1).getTextContent());
        		titleName.setText(currentNode.getChildNodes().item(5).getTextContent());
        		burb.setText(currentNode.getChildNodes().item(9).getTextContent());
        		
        		ImageLoader imgLoader = new ImageLoader(con.getApplicationContext());
        		imgLoader.DisplayImage(currentNode.getChildNodes().item(17).getTextContent(), 0, img);
			}
		}
    }
    public boolean onTouch(View v, MotionEvent event) {
    	boolean value= super.onTouch(v, event);
		if(event.getAction()==MotionEvent.ACTION_UP&&!isMove){
			int page=getCurrentPage();
			TheNationMain main=(TheNationMain) getContext();
			main.clickNews(list.item(page*2+1));
		}
		return value;
	}
}
